Introduction
Mathjax
A little math formula :
\[x = \sum_{i=1}^{n} \sqrt{\frac{y}{i}} \]
Analysis
R output
R output is typically shown in the monospace font (here an example with the mtcars dataset in the subfolder data/):
# Import dataset from the data/ folder
mtcars <- read.csv("data/mtcars.csv")
summary(mtcars[,1:4])## mpg cyl disp hp
## Min. :10.40 Min. :4.000 Min. : 71.1 Min. : 52.0
## 1st Qu.:15.43 1st Qu.:4.000 1st Qu.:120.8 1st Qu.: 96.5
## Median :19.20 Median :6.000 Median :196.3 Median :123.0
## Mean :20.09 Mean :6.188 Mean :230.7 Mean :146.7
## 3rd Qu.:22.80 3rd Qu.:8.000 3rd Qu.:326.0 3rd Qu.:180.0
## Max. :33.90 Max. :8.000 Max. :472.0 Max. :335.0
Tables
Here is a sample table output.
tab <- aggregate(. ~ Species, data = iris, mean)
kable(tab,
caption = "Species-specific mean lengths and widths.")| Species | Sepal.Length | Sepal.Width | Petal.Length | Petal.Width |
|---|---|---|---|---|
| setosa | 5.006 | 3.428 | 1.462 | 0.246 |
| versicolor | 5.936 | 2.770 | 4.260 | 1.326 |
| virginica | 6.588 | 2.974 | 5.552 | 2.026 |
Tabbed sections
Comparison between the classical tabs and the pill tabs:
Classical tabs
Classical tabs without fading effect.
First tab
boxplot(rnorm(100), rnorm(100))Figure 1: Boxplot made with the basic graphics package
Second tab
Cum eaque dicta architecto culpa eius. Dignissimos officiis error exercitationem. Adipisci odit ad ea iusto fugiat laborum maiores. Dolore sunt et veritatis alias nesciunt maxime cumque. Culpa aut non ea. Culpa ex quia debitis sint eveniet cum.
Pill tabs
Pill tabs with fading effect.
First tab
plot(rnorm(100), rnorm(100))Figure 2: Scatterplot made with the basic graphics package
Second tab
Cum eaque dicta architecto culpa eius. Dignissimos officiis error exercitationem. Adipisci odit ad ea iusto fugiat laborum maiores. Dolore sunt et veritatis alias nesciunt maxime cumque. Culpa aut non ea. Culpa ex quia debitis sint eveniet cum. Non eos ex aperiam dolor hic. Consectetur delectus placeat rerum consequuntur ducimus sed fugiat non. Aut voluptatem et et. Omnis sunt veniam omnis ullam. Dolorem eius perspiciatis et veniam hic reprehenderit ipsam ut. Exercitationem rem eius quo. Nemo quis in voluptatibus ex.
Figures
A base graphics histogram (click on the figure to enlarge it):
hist(rnorm(100))Figure 3: A Histogram made with the basic graphics package
Interactive figures with plotly
If the package ‘plotly’ is installed, the following code block will be executed:
# If plotly is installed run:
p <- plotly::plot_ly(data = mtcars, x = ~mpg, y = ~wt, color = ~cyl)
plotly::add_markers(p)Figure 4: This is the interactive htmlwidget ‘plotly’
Conclusions
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
Bibliography
Link a .bib document via the YAML header, and the bibliography will be printed at the very end (as usual). The default bibliography style is provided in the sage-harvard.csl file (do not delete), which adopts the SAGE Harvard reference style.
References can be cited directly within the document using the R Markdown equivalent of the citation system [@key], where key is the citation key in the first line of the entry in the .bib file. Example: (Taylor and Green, 1937). To cite multiple entries, separate the keys by semicolons, e.g. (Kamm, 2000; Knupp, 1999).
There is also the package citr, which I highly recommend: citr provides functions and an RStudio add-in to search a BibTeX-file to create and insert formatted Markdown citations into the current document. If you are using the reference manager Zotero the add-in can access your reference database directly.
Software
If you want to include a paragraph on the software used, here is some example text/code to get the current R and package versions. The code to generate a bibliography file including all package references has been already added at the beginning of this script (code chunk ‘generate-package-refs’).
All analyses were performed using the statistical software R (version 4.1.2) (R Core Team, 2021). This report, including tables and figures, was generated using the packages ‘rmarkdown’ (version 2.14) (Allaire et al., 2022), and ‘knitr’ (version 1.39) (Xie, 2022).